/***************************************************************************
 *   Copyright (C) 2011  by TinySofts                                      *
 *   tinysofts@gmail.com                                                   *
 *   All Rights Reserved.                                                  *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   Refer to http://code.google.com/p/tinydict/                           *
 ***************************************************************************/
/*
    StarDict Class Definiation
    Status:Open;ReleaseReady;M
*/

#ifndef TDICT_H
#define TDICT_H

#include "basedict.h"
#include "dictzip.h"
class TDict:public BaseDict
{
public:
    TDict();
    ~TDict() {
        if(dz)
            delete dz;
        if(idx.isOpen())
            idx.close();
    }

    QByteArray lookUpDict(const QString & word);
    QByteArray lookUpDict2(const QString & word);
    bool setPath(QString path, QString file);
    bool init();
    bool reset();
    
    QString getWord(int, int &, int &);
    QByteArray readDict(int offset,int size);
            
private:;
    bool initDictDB(QString path, QString name);
    QString findWord(int, int &, int &);
    
public:
    int wordNum;

private:
    QString dictname;
    QString dictpath;
    QFile idx;
    DictZip * dz;
    //uchar * mapped;
    bool state;
    QList<int> wordlist;
};

#endif // TDICT_H
